package com.ch.home.controller.dishController;

import com.ch.home.bean.DishRecipes;
import com.ch.home.service.serviceImpl.restDishServiceImpl.DishRecipesServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * Created by CHEN on 2019/8/28.
 */
@RestController
@RequestMapping("/dish/recipes")
public class DishRecipesController {


    @Autowired
    DishRecipesServiceImpl dishRecipesService;


    /**
     * @return
     */
    @PostMapping("/getAll")
    public HashMap getAllInfo(@RequestParam(required = false) Integer dishId) {
        HashMap<Object, Object> result;
        result = dishRecipesService.getAll(new DishRecipes(null, dishId, null, null, null,null));
        return result;
    }

    @PostMapping("/add")
    public HashMap addHistory(@RequestParam(required = false) Integer dishId,@RequestParam(required = false) String recipesContent,@RequestParam(required = false) Integer step) {

        HashMap<Object, Object> result;
        result = dishRecipesService.add(new DishRecipes(null,dishId,recipesContent,step,null,null));
        return result;
    }


    @PostMapping("/update")
    public HashMap updateHistory(@RequestParam(required = false) Integer recipesId,@RequestParam(required = false) Integer dishId,@RequestParam(required = false) String recipesContent,@RequestParam(required = false) Integer step) {
        HashMap<Object, Object> result;
        result = dishRecipesService.update(new DishRecipes(recipesId,dishId,recipesContent,step,null,null));
        return result;
    }





}
